<html>
<head><meta charset="utf-8"><title>How to identify what target a binary was built for · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html">How to identify what target a binary was built for</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="243188088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243188088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243188088">(Jun 18 2021 at 17:20)</a>:</h4>
<p>This may not necessarily have a rust specific answer but I have a pipeline whtat (unfortunately) produces a binary that is ambiguously built for macos or linux for x86_64 or aarch64. Is there something I can do to check what target a binary was built for?</p>



<a name="243188655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243188655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243188655">(Jun 18 2021 at 17:26)</a>:</h4>
<p>what is the binary format?</p>



<a name="243188779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243188779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243188779">(Jun 18 2021 at 17:27)</a>:</h4>
<p>it should be ELF for Linux or Mach-O for macOS</p>



<a name="243188803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243188803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243188803">(Jun 18 2021 at 17:27)</a>:</h4>
<p>then ELF has a machine type in the header</p>



<a name="243188869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243188869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243188869">(Jun 18 2021 at 17:28)</a>:</h4>
<p>I don't know further mach-o details</p>



<a name="243189202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243189202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243189202">(Jun 18 2021 at 17:31)</a>:</h4>
<p>Newb question but what do you mean by binary format? It's an executable rust binary (so not some kind of library <code>.rlib</code>, <code>.a</code>, <code>.so</code>, etc). There's just been an oversight on something I'm working on and it's ambigous as to what the real binary actually is. But supposedly I could use something like <code>otool</code>, or <code>file</code> to get enough information to infer OS and architecture?</p>



<a name="243189312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243189312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243189312">(Jun 18 2021 at 17:32)</a>:</h4>
<p>"rust binary" is not a thing on its own-- they're just target-specific executables</p>



<a name="243189324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243189324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243189324">(Jun 18 2021 at 17:32)</a>:</h4>
<p>but yes, <code>file</code> should tell you</p>



<a name="243189369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/How%20to%20identify%20what%20target%20a%20binary%20was%20built%20for/near/243189369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/How.20to.20identify.20what.20target.20a.20binary.20was.20built.20for.html#243189369">(Jun 18 2021 at 17:33)</a>:</h4>
<p>awesome, thanks for taking the time to answer my newb question <span aria-label="pray" class="emoji emoji-1f64f" role="img" title="pray">:pray:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>